
// 库位坐标
const coord = { x: 20, y: 3, z: 10 };//世界坐标系
// 库存数据
let goodsData = [
	{ areaNo: '国内存储区', spaceNo: '2-1-3', flightNo:'CA213', goodsNo: '8932489123', goodsType: 'pallet', state: 'storing'   },
	{ areaNo: '国内存储区', spaceNo: '3-2-1', flightNo:'CZ321', goodsNo: '8932489234', goodsType: 'bag',    state: 'stored'    },
	{ areaNo: '国内存储区', spaceNo: '5-3-1', flightNo:'MU531', goodsNo: '8932489245', goodsType: 'bag',    state: 'releasing' },
	{ areaNo: '国内存储区', spaceNo: '4-2-2', flightNo:'MU422', goodsNo: '8932489311', goodsType: 'bag',    state: 'storing'   }
];
// 库位状态
let warehouseStates = [
	{ areaNo: '国内存储区', spaceNo: '1-1-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '2-1-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '3-1-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '4-1-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '5-1-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '6-1-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '7-1-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '8-1-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '9-1-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo:'10-1-1', deviceState: 'Maintenance' },
	{ areaNo: '国内存储区', spaceNo: '1-2-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '2-2-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '3-2-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '4-2-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '5-2-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '6-2-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '7-2-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '8-2-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo:'10-2-1', deviceState: 'Failure' },
	{ areaNo: '国内存储区', spaceNo: '1-3-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '2-3-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '3-3-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '4-3-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '5-3-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '6-3-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '7-3-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '8-3-1', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo:'10-3-1', deviceState: 'Releasing' },
	{ areaNo: '国内存储区', spaceNo: '1-1-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '2-1-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '3-1-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '4-1-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '5-1-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '6-1-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '7-1-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '8-1-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '9-1-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '1-2-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '2-2-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '3-2-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '4-2-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '5-2-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '6-2-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '7-2-2', deviceState: 'Normal' },
	{ areaNo: '国内存储区', spaceNo: '8-2-2', deviceState: 'Normal' }
];
// 库位数据 
// coordC:笛卡尔坐标系(Cartesian Coordinate System) 
// coordW:世界坐标系 (World coordinate system) x-右 y-上 z-前
let warehouses = [
	{ areaNo: '国内存储区', spaceNo: '1-1-1', coordW: [1,1,1], coordC: [1,1,1], state: 1 ,usedTimes: 510},
	{ areaNo: '国内存储区', spaceNo: '2-1-1', coordW: [2,1,1], coordC: [2,1,1], state: 1 ,usedTimes: 520},
	{ areaNo: '国内存储区', spaceNo: '3-1-1', coordW: [3,1,1], coordC: [3,1,1], state: 1 ,usedTimes: 530},
	{ areaNo: '国内存储区', spaceNo: '4-1-1', coordW: [4,1,1], coordC: [4,1,1], state: 1 ,usedTimes: 540},
	{ areaNo: '国内存储区', spaceNo: '5-1-1', coordW: [5,1,1], coordC: [5,1,1], state: 1 ,usedTimes: 550},
	{ areaNo: '国内存储区', spaceNo: '6-1-1', coordW: [6,1,1], coordC: [6,1,1], state: 1 ,usedTimes: 560},
	{ areaNo: '国内存储区', spaceNo: '7-1-1', coordW: [7,1,1], coordC: [7,1,1], state: 1 ,usedTimes: 570},
	{ areaNo: '国内存储区', spaceNo: '8-1-1', coordW: [8,1,1], coordC: [8,1,1], state: 1 ,usedTimes: 580},
	{ areaNo: '国内存储区', spaceNo: '9-1-1', coordW: [9,1,1], coordC: [9,1,1], state: 1 ,usedTimes: 590},
	{ areaNo: '国内存储区', spaceNo:'10-1-1', coordW:[10,1,1], coordC:[10,1,1], state: 1 ,usedTimes: 50 },
	{ areaNo: '国内存储区', spaceNo: '1-2-1', coordW: [1,2,1], coordC: [1,2,1], state: 1 ,usedTimes: 891},
	{ areaNo: '国内存储区', spaceNo: '2-2-1', coordW: [2,2,1], coordC: [2,2,1], state: 1 ,usedTimes: 892},
	{ areaNo: '国内存储区', spaceNo: '3-2-1', coordW: [3,2,1], coordC: [3,2,1], state: 1 ,usedTimes: 893},
	{ areaNo: '国内存储区', spaceNo: '4-2-1', coordW: [4,2,1], coordC: [4,2,1], state: 1 ,usedTimes: 894},
	{ areaNo: '国内存储区', spaceNo: '5-2-1', coordW: [5,2,1], coordC: [5,2,1], state: 1 ,usedTimes: 895},
	{ areaNo: '国内存储区', spaceNo: '6-2-1', coordW: [6,2,1], coordC: [6,2,1], state: 1 ,usedTimes: 896},
	{ areaNo: '国内存储区', spaceNo: '7-2-1', coordW: [7,2,1], coordC: [7,2,1], state: 1 ,usedTimes: 897},
	{ areaNo: '国内存储区', spaceNo: '8-2-1', coordW: [8,2,1], coordC: [8,2,1], state: 1 ,usedTimes: 898},
	{ areaNo: '国内存储区', spaceNo:'10-2-1', coordW:[10,2,1], coordC:[10,2,1], state: 1 ,usedTimes: 899},
	{ areaNo: '国内存储区', spaceNo: '1-3-1', coordW: [1,3,1], coordC: [1,3,1], state: 1 ,usedTimes: 711},
	{ areaNo: '国内存储区', spaceNo: '2-3-1', coordW: [2,3,1], coordC: [2,3,1], state: 1 ,usedTimes: 712},
	{ areaNo: '国内存储区', spaceNo: '3-3-1', coordW: [3,3,1], coordC: [3,3,1], state: 1 ,usedTimes: 713},
	{ areaNo: '国内存储区', spaceNo: '4-3-1', coordW: [4,3,1], coordC: [4,3,1], state: 1 ,usedTimes: 714},
	{ areaNo: '国内存储区', spaceNo: '5-3-1', coordW: [5,3,1], coordC: [5,3,1], state: 1 ,usedTimes: 715},
	{ areaNo: '国内存储区', spaceNo: '6-3-1', coordW: [6,3,1], coordC: [6,3,1], state: 1 ,usedTimes: 716},
	{ areaNo: '国内存储区', spaceNo: '7-3-1', coordW: [7,3,1], coordC: [7,3,1], state: 1 ,usedTimes: 717},
	{ areaNo: '国内存储区', spaceNo: '8-3-1', coordW: [8,3,1], coordC: [8,3,1], state: 1 ,usedTimes: 718},
	{ areaNo: '国内存储区', spaceNo:'10-3-1', coordW:[10,3,1], coordC:[10,3,1], state: 1 ,usedTimes: 719},
	{ areaNo: '国内存储区', spaceNo: '1-3-2', coordW: [1,3,2], coordC: [1,3,2], state: 1 ,usedTimes: 731},
	{ areaNo: '国内存储区', spaceNo: '2-3-2', coordW: [2,3,2], coordC: [2,3,2], state: 1 ,usedTimes: 732},
	{ areaNo: '国内存储区', spaceNo: '3-3-2', coordW: [3,3,2], coordC: [3,3,2], state: 1 ,usedTimes: 733},
	{ areaNo: '国内存储区', spaceNo: '4-3-2', coordW: [4,3,2], coordC: [4,3,2], state: 1 ,usedTimes: 734},
	{ areaNo: '国内存储区', spaceNo: '5-3-2', coordW: [5,3,2], coordC: [5,3,2], state: 1 ,usedTimes: 735},
	{ areaNo: '国内存储区', spaceNo: '6-3-2', coordW: [6,3,2], coordC: [6,3,2], state: 1 ,usedTimes: 736},
	{ areaNo: '国内存储区', spaceNo: '7-3-2', coordW: [7,3,2], coordC: [7,3,2], state: 1 ,usedTimes: 737},
	{ areaNo: '国内存储区', spaceNo: '8-3-2', coordW: [8,3,2], coordC: [8,3,2], state: 1 ,usedTimes: 738},
	{ areaNo: '国内存储区', spaceNo:'10-3-2', coordW:[10,3,2], coordC:[10,3,2], state: 1 ,usedTimes: 739},
	{ areaNo: '国内存储区', spaceNo: '1-1-2', coordW: [1,1,2], coordC: [1,1,2], state: 1 ,usedTimes: 161},
	{ areaNo: '国内存储区', spaceNo: '2-1-2', coordW: [2,1,2], coordC: [2,1,2], state: 1 ,usedTimes: 162},
	{ areaNo: '国内存储区', spaceNo: '3-1-2', coordW: [3,1,2], coordC: [3,1,2], state: 1 ,usedTimes: 163},
	{ areaNo: '国内存储区', spaceNo: '4-1-2', coordW: [4,1,2], coordC: [4,1,2], state: 1 ,usedTimes: 164},
	{ areaNo: '国内存储区', spaceNo: '5-1-2', coordW: [5,1,2], coordC: [5,1,2], state: 1 ,usedTimes: 165},
	{ areaNo: '国内存储区', spaceNo: '6-1-2', coordW: [6,1,2], coordC: [6,1,2], state: 1 ,usedTimes: 166},
	{ areaNo: '国内存储区', spaceNo: '7-1-2', coordW: [7,1,2], coordC: [7,1,2], state: 1 ,usedTimes: 167},
	{ areaNo: '国内存储区', spaceNo: '8-1-2', coordW: [8,1,2], coordC: [8,1,2], state: 1 ,usedTimes: 168},
	{ areaNo: '国内存储区', spaceNo: '9-1-2', coordW: [9,1,2], coordC: [9,1,2], state: 1 ,usedTimes: 169},
	{ areaNo: '国内存储区', spaceNo: '1-2-2', coordW: [1,2,2], coordC: [1,2,2], state: 1 ,usedTimes: 281},
	{ areaNo: '国内存储区', spaceNo: '2-2-2', coordW: [2,2,2], coordC: [2,2,2], state: 1 ,usedTimes: 282},
	{ areaNo: '国内存储区', spaceNo: '3-2-2', coordW: [3,2,2], coordC: [3,2,2], state: 1 ,usedTimes: 283},
	{ areaNo: '国内存储区', spaceNo: '4-2-2', coordW: [4,2,2], coordC: [4,2,2], state: 1 ,usedTimes: 284},
	{ areaNo: '国内存储区', spaceNo: '5-2-2', coordW: [5,2,2], coordC: [5,2,2], state: 1 ,usedTimes: 285},
	{ areaNo: '国内存储区', spaceNo: '6-2-2', coordW: [6,2,2], coordC: [6,2,2], state: 1 ,usedTimes: 286},
	{ areaNo: '国内存储区', spaceNo: '7-2-2', coordW: [7,2,2], coordC: [7,2,2], state: 1 ,usedTimes: 287},
	{ areaNo: '国内存储区', spaceNo: '8-2-2', coordW: [8,2,2], coordC: [8,2,2], state: 1 ,usedTimes: 288},
	{ areaNo: '国内存储区', spaceNo: '1-3-2', coordW: [1,3,2], coordC: [1,3,2], state: 1 ,usedTimes: 201},
	{ areaNo: '国内存储区', spaceNo: '2-3-2', coordW: [2,3,2], coordC: [2,3,2], state: 1 ,usedTimes: 202},
	{ areaNo: '国内存储区', spaceNo: '3-3-2', coordW: [3,3,2], coordC: [3,3,2], state: 1 ,usedTimes: 203},
	{ areaNo: '国内存储区', spaceNo: '4-3-2', coordW: [4,3,2], coordC: [4,3,2], state: 1 ,usedTimes: 1204},
	{ areaNo: '国内存储区', spaceNo: '5-3-2', coordW: [5,3,2], coordC: [5,3,2], state: 1 ,usedTimes: 1205},
	{ areaNo: '国内存储区', spaceNo: '6-3-2', coordW: [6,3,2], coordC: [6,3,2], state: 1 ,usedTimes: 1206},
	{ areaNo: '国内存储区', spaceNo: '7-3-2', coordW: [7,3,2], coordC: [7,3,2], state: 1 ,usedTimes: 1207},
	{ areaNo: '国内存储区', spaceNo: '8-3-2', coordW: [8,3,2], coordC: [8,3,2], state: 1 ,usedTimes: 1208},
	{ areaNo: '国内存储区', spaceNo: '1-4-2', coordW: [1,4,2], coordC: [1,4,2], state: 1 ,usedTimes: 1201},
	{ areaNo: '国内存储区', spaceNo: '2-4-2', coordW: [2,4,2], coordC: [2,4,2], state: 1 ,usedTimes: 1202},
	{ areaNo: '国内存储区', spaceNo: '3-4-2', coordW: [3,4,2], coordC: [3,4,2], state: 1 ,usedTimes: 1223},
	{ areaNo: '国内存储区', spaceNo: '4-4-2', coordW: [4,4,2], coordC: [4,4,2], state: 1 ,usedTimes: 1224},
	{ areaNo: '国内存储区', spaceNo: '5-4-2', coordW: [5,4,2], coordC: [5,4,2], state: 1 ,usedTimes: 1225},
	{ areaNo: '国内存储区', spaceNo: '6-4-2', coordW: [6,4,2], coordC: [6,4,2], state: 1 ,usedTimes: 1226},
	{ areaNo: '国内存储区', spaceNo: '7-4-2', coordW: [7,4,2], coordC: [7,4,2], state: 1 ,usedTimes: 227},
	{ areaNo: '国内存储区', spaceNo: '2-1-3', coordW: [2,1,3], coordC: [2,1,3], state: 1 ,usedTimes: 228},
];

// 自动生成数据
goodsData =[];
warehouseStates =[];
warehouses =[];
(function genData() {
	for(let z=1; z<=coord.z; z++) {
		for(let y=1; y<=coord.y; y++) {
			for(let x=1; x<=coord.x; x++) {
				let rdm = Math.ceil(Math.random() * 10);
				if(rdm>3){
					// 70%行李量
					let gt ='bag';
					if(x>18){
						// 末端是空框
						gt = 'pallet';
					}
					if(x>10 && x<=18){
						// 不存行李
					}else{
						let state = rdm/2 === 1 ? 'stored' : rdm/3 === 1 ? 'storing' : rdm/4 === 1 ? 'releasing' : 'stored';
						goodsData.push({ areaNo: '国内存储区', spaceNo: `${x}-${y}-${z}`, flightNo:'CA'+`${x}${y}${z}`, goodsNo: '893248'+`${z}${y}${x}`, goodsType: `${gt}`, state: `${state}` });
					}
				}
				
				let rdm1 = Math.ceil(Math.random() * 100);
				let deviceState = rdm1/1 === 1 ? 'Releasing' : rdm1/2 === 1 ? 'Maintenance' : 'Normal';
				warehouseStates.push({ areaNo: '国内存储区', spaceNo: `${x}-${y}-${z}`, deviceState: `${deviceState}` });
				
				let usedTimes=z+y*50+(20-x)*100;//使用次数
				let dwellTime=(z+y*50+x*100)/100;//停留时间
				if(z<3 && x>18){
					// 该位置没库位
				}else{
					warehouses.push({ areaNo: '国内存储区', spaceNo: `${x}-${y}-${z}`, coordW: [`${x}`,`${y}`,`${z}`], coordC: [`${x}`,`${y}`,`${z}`], state: 1 ,usedTimes: `${usedTimes}`,dwellTime: `${dwellTime}` });
				}
			}
		}
	}
})();
//console.log(goodsData);
//console.log(warehouseStates);
//console.log(warehouses);

// 统计数据
const summary = { name: "国内存储区", total: warehouses.length, used: goodsData.length };
//const summary = { name: "国内存储区", total: 588, used: 588 };
 